# define switch DEBUG SYB TCL

# DEBUG=1	debug edition
# default 	release edition

# ORA=1		oracle edition
# default	sybase edition


# ORACLE_HOME 	oracle home dir
# SYBASE	sybase home dir

ORA= 1
SYB=
DEBUG= 1
_LINUX=1
SRC_HOME=./
CC = g++  -D_REENTRANT -D_LINUX=$(_LINUX)
CCEXE = $(CC) -lpthread 
CCDLL = $(CC) -shared -lpthread
ifdef ORA
ORA_DB=1
SYB_DB=0
endif

ifdef SYB
ORA_DB=0
SYB_DB=1
endif

SYB_DB=0
ORA_DB=0

ifdef PURIFY
DEBUG = 1
NDEBUG = 0
CCEXE := purify -best-effort $(CCEXE)
endif

ifdef QUANTIFY
DEBUG = 1
NDEBUG = 0
#CCEXE := quantify -best-effort $(CCEXE) -Bdynamic 
CCEXE := $(CCEXE) -pg -a
CCDLL := $(CCDLL) -pg -a
endif

ifdef DEBUG
#CFLAG = -g -D_DEBUG -L. -L$(SRC_HOME)/lib -I$(SRC_HOME)/include +w
CFLAG = -g -D_DEBUG -L. -L$(SRC_HOME)/lib -I$(SRC_HOME)/include -L$(SRC_COMMON)/lib -I$(SRC_COMMON)/include 

else
CFLAG = -L. -L$(SRC_HOME)/lib -I$(SRC_HOME)/include -s  

endif

ifeq "$(ORA_DB)" "1"
CDBFLAG = -D_ORACLE -L$(ORACLE_HOME)/lib -I$(ORACLE_HOME)/rdbms/demo \
	-I$(ORACLE_HOME)/plsql/public -I$(ORACLE_HOME)/network/public \
	-I$(ORACLE_HOME)/include -I$(ORACLE_HOME)/rdbms/public -lclntsh -laio
DBFLAG = -D_ORACLE
endif

ifeq "$(SYB_DB)" "1"
CDBFLAG = -D_SYBASE -DOTL_SYBASE -L$(SYBASE)/lib -I$(SYBASE)/include \
	-lct -lcs -lcomn -ldl -lintl -ltcl -lsocket -lnsl -lblk
DBFLAG= -D_SYBASE
endif


all : keepex
ifdef DEBUG
	@echo debug edition build ok .
else
	@echo release edition build ok.
endif



keepex: keepex.cpp estools.cpp estools.h emcfg.cpp emcfg.h emtools.cpp emtools.h
	@echo build keepex
	@$(CCEXE) $(CFLAG) -o keepex keepex.cpp estools.cpp estools.h emcfg.cpp emcfg.h emtools.cpp emtools.h \
		-lpthread  $(CDBFLAG)

install: keepex
	@echo cp all modules of keepex
	@cp keepex $(SRC_HOME)/bin

clean:
	@echo clean all module
	@rm -f keepex
	@rm -f *.o
	@rm -f core *.core core.*
	
